﻿using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using Inovout.ArcGis;
using Inovout.Gis.Geometry;
using ESRI.ArcGIS.Geometry;

namespace Inovout.Gis.Land.DiLei.GuiHua
{
    public class GuiHuaGeometryFactory :GeometryFactory
    {
        public override IGeometryLayerInfo CreateGeometryLayer(IFeatureLayer arcFeatureLayer)
        {
            switch (FeatureLayerInfo.GetLayerName(arcFeatureLayer))
            {
                case "G31_H_PY":
                    JQNDiLeiLayer.Instance.PolygonLayer = new DiLeiPolygonLayer(new FeatureLayerInfo(arcFeatureLayer));
                    return JQNDiLeiLayer.Instance.PolygonLayer;
                case "G32_H_PL":
                    JQNDiLeiLayer.Instance.LineLayer = new DiLeiLineLayer(new FeatureLayerInfo(arcFeatureLayer));
                    return JQNDiLeiLayer.Instance.LineLayer; ;
                case "G33_H_PT":
                    JQNDiLeiLayer.Instance.PointLayer = new DiLeiPointLayer(new FeatureLayerInfo(arcFeatureLayer));
                    return JQNDiLeiLayer.Instance.PointLayer;
                default:
                    return null;

            }
        }
        public override IGeometryInfo CreateGeometry(IGeometryLayerInfo geometryLayerInfo, IFeature arcFeature)
        {
            switch (geometryLayerInfo.Name)
            {
                case "G31_H_PY":
                case "G32_H_PL":
                case "G33_H_PT":
                    return CreateDiLeiGeometry(arcFeature);
                default:
                    return null;

            }
        }
        private IGeometryInfo CreateDiLeiGeometry(IFeature arcFeature)
        {
            switch (arcFeature.Shape.GeometryType)
            {
                case esriGeometryType.esriGeometryPolyline:
                    return new DiLeiLine(ArcGeometryHelper.CreateGeometry(arcFeature) as PolyLineInfo);
                case esriGeometryType.esriGeometryPoint:
                     return new DiLeiPoint(ArcGeometryHelper.CreateGeometry(arcFeature) as PointInfo);
                case esriGeometryType.esriGeometryPolygon:
                    return new DiLeiPolygon(ArcGeometryHelper.CreateGeometry(arcFeature) as PolygonInfo);
                default:
                    return null;
            }
        }
    }
}
